// class Solution {
// public:
//     string solve(string str) {
//         reverse(str.begin(), str.end());
//         return str;
//     }
// };

class Solution {
public:
    string solve(string str) {
        int left = 0;
        int right = str.size()-1;
        while(left < right)
        {
            swap(str[left],str[right]);
            left++;
            right--;
        }

        return str;
    }
};

class Solution {
public:
    int maxLength(vector<int>& arr) {
        unordered_map<int, int> myMap;
        int left = 0;
        int right = 0;
        int ret_len = 0;

        while(right < arr.size())
        {
            if(myMap.count(arr[right]) == 0)
            {
                myMap[arr[right]]++;
                right++;
                ret_len = max(ret_len, right-left);
            }
            else if(myMap.count(arr[right]) == 1)
            {
                while(myMap.count(arr[right]) == 1)
                {
                    myMap.erase(arr[left]);
                    left++;          
                }
            }
        }

        return ret_len;
    }
};

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0;
        int right = height.size()-1;
        int maxNum = 0;
        int h = 0;
        while(left < right)
        {
            h = min(height[left],height[right]);
            maxNum = max(maxNum, (right-left)*h);
            if(height[left] < height[right])
            {
                left++;
            }
            else 
            {
                right--;
            }
        }

        return maxNum;
    }
};

class Solution {
public:
    int minmumNumberOfHost(int n, vector<vector<int> >& startEnd) {
        if(startEnd.size() == 0) return 0;
        if(startEnd.size() == 1) return 1;

        int count = 1;
        sort(startEnd.begin(), startEnd.end(),[&](vector<int>& v1, vector<int>& v2){
            bool ret = false;
            if(v1[0] < v2[0])
            {
                ret = true;
            }
            else if(v1[0] == v2[0] && v1[1] < v2[1])
            {
                ret = true;
            }

            return ret;
        });

        for(int i = 1; i < startEnd.size(); ++i)
        {
            if(startEnd[i][0] < startEnd[i-1][1])
            {
                count++;
            }
        }

        return count;
    }
};
